import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:kxy_flutter_app/helper/http.dart';

class AppInfoModel extends ChangeNotifier {
  String homeTitle = '首页';
  String newsTitle = '新闻';
  String centerTitle = '我的';
  String examinationTitle = '考试';
  String trainTitle = '课程';
  String companyTitle = '矿校云';
  String logoUrl = '';

  Future loadAppInfo() async {
    var res = await Http.instance.post('/sys/tenantsysconfig/appinfo');
    if (res.code == 200) {
      if (res.data['homeTitle'] != null) {
        homeTitle = res.data['homeTitle'];
      }
      if (res.data['newsTitle'] != null) {
        newsTitle = res.data['newsTitle'];
      }
      if (res.data['centerTitle'] != null) {
        centerTitle = res.data['centerTitle'];
      }
      if (res.data['examinationTitle'] != null) {
        examinationTitle = res.data['examinationTitle'];
      }
      if (res.data['trainTitle'] != null) {
        trainTitle = res.data['trainTitle'];
      }
      if (res.data['companyTitle'] != null) {
        companyTitle = res.data['companyTitle'];
      }
      if (res.data['logoUrl'] != null) {
        logoUrl = res.data['logoUrl'];
      }
      notifyListeners();
    } else {
      Fluttertoast.showToast(msg: res.msg);
    }
  }
}
